package com.safeluck.floatwindow.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

/**
 * Created by Administrator on 2017/10/18.
 */

public class TimeUtil {
    /**
     *
     * @param timeMillons
     * @return 2017-2-11 12:11:32
     */
    public static String formatCurTime(long timeMillons){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
        return sdf.format(timeMillons);
    }
    public static String formatTime(long timeMillons){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");

        return sdf.format(timeMillons);
    }
    public static String video_formatTime(long timeMillons){
        SimpleDateFormat sdf = new SimpleDateFormat("yyMMddHHmmss");

        return sdf.format(timeMillons);
    }
    public static long video_formatTime(String timeMillons){
        SimpleDateFormat sdf = new SimpleDateFormat("yyMMddHHmmss");
        Date date = null;
        try {
            date = sdf.parse(timeMillons);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return date.getTime();
    }
    /**
     *
     * @param timeMillons
     * @return  12:11:32
     */
    public static String formatCurHTime(long timeMillons){
        SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
        sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
        return sdf.format(timeMillons);
    }
}
